package com.thoughtworks.twu.module1;

public final class TriangleExercises {
    private TriangleExercises() {

    }

    public static void run() {
        easiestExerciseEver();
        drawHorizontalLine(8);
        drawVerticalLine(3);
        drawRightTriangle(3);
    }

    private static void easiestExerciseEver() {
        Utilities.printTitle("Easiest exercise ever");
        System.out.println("*");
    }

    private static void drawHorizontalLine(int n) {
        Utilities.printTitle(String.format("Draw a horizontal line (with n = %d)", n));
        Utilities.printLineOfAsterisks(n);
    }

    private static void drawVerticalLine(int n) {
        Utilities.printTitle(String.format("Draw a vertical line (with n = %d)", n));

        for (int i = 0; i < n; i++) {
            System.out.println("*");
        }
    }

    private static void drawRightTriangle(int n) {
        Utilities.printTitle(String.format("Draw a right triangle (with n = %d)", n));

        for (int i = 1; i <= n; i++) {
            Utilities.printLineOfAsterisks(i);
        }
    }
}
